package com.swdegao.iot.netty.udp.server.guoxinudp;

import java.util.concurrent.TimeUnit;

import com.swdegao.iot.netty.server.channelhandler.HeartBeatClientHandler;
import org.springframework.beans.factory.annotation.Autowired;

import com.swdegao.iot.SwdegaoIotMgtServerApplication;
import com.swdegao.iot.netty.entity.MyProps;
import com.swdegao.iot.netty.entity.Parameter;
import com.swdegao.iot.netty.udp.server.channelhandler.ParseMessgaeHandler;
import com.swdegao.iot.netty.udp.server.channelhandler.PushMessgaeHandler;
import com.swdegao.iot.netty.udp.server.channelhandler.SaveMessgaeHandler;
import com.swdegao.iot.netty.server.decoder.DG_DATADecoder;

import io.netty.channel.*;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.util.concurrent.DefaultEventExecutorGroup;
import io.netty.util.concurrent.EventExecutor;
import io.netty.util.concurrent.EventExecutorGroup;

public class GuoXinUdpNettyServerChannelInitializer extends ChannelInitializer<NioDatagramChannel> {
	private EventLoopGroup pusheventloop = new NioEventLoopGroup();
	@Override
	protected void initChannel(NioDatagramChannel socketChannel) throws Exception {
		// UDp
		ChannelPipeline pipeline = socketChannel.pipeline();
		pipeline.addLast(new GuoXin_UDP_Decoder(1<<20,17,2,-19,0));
		pipeline.addLast(new GuoXinUdpParseMessgaeHandler());// 推送
		pipeline.addLast(new GuoXinUdpSaveMessgaeHandler());// 存储
		pipeline.addLast(pusheventloop,new GuoXinUdpPushMessgaeHandler());


	}
}
